package it.low.game.client.server;

import it.low.game.core.element.ActiveElement;
import it.low.game.core.location.MapPoint;
import it.low.game.core.message.ClientEvent;
import it.low.game.core.message.ElementState;
import it.low.game.core.message.PlayerEvent;

import java.util.Collection;
import java.util.Set;

public class ClientServerNetworking implements ClientServerInterface {

	public int init(long clientId) {
		return 0;
	}
	
	public void close(long clientId) {
	}
	
	// SEND EVENTS TO THE SERVER

	public void sendClientEvent(ClientEvent clientEvent) {
	}

	public void sendPlayerEvent(PlayerEvent playerEvent) {
	}
	
	// RECEIVE THE WORLD STATE FROM THE SERVER

	public void receiveWorldState(long elapsedTime) {
	}

	public ElementState receivePlayerState(long playerId) {
		return null;
	}

	public Set<ElementState> receiveElementsState(long playerId) {
		return null;
	}
	
	// TO START THE GAME
	
	public ActiveElement loadPlayer(long clientId) {
		return null;
	}

	public String[][] loadMap() {
		return null;
	}

	public Collection<ActiveElement> loadBots() {
		return null;
	}

	public ActiveElement initPlayer(long playerId, int size, MapPoint mapPosition) {
		return null;
	}

	public ActiveElement initBot(long botId, int size) {
		return null;
	}
	
//	private DatagramSocket socket = null;
//	private byte[] buf = null;
//	private InetAddress address = null;
//	
//	public ClientServerNetworking(){
//		try {
//			
//			socket = new DatagramSocket();
//			buf = new byte[256];
//			address = InetAddress.getLocalHost();
//			ClientLogManager.logMsg("Client address = "+address);
//			
//		} catch (SocketException e) {
//			ClientLogManager.logErr("call new ClientServerNetworking()", e);
//		} catch (UnknownHostException e) {
//			ClientLogManager.logErr("call new ClientServerNetworking()", e);
//		}
//	}
//	
//	public int checkConnection(){
//		int connectionStatus = 0;
//		if(socket!=null && address!=null){
//			try{
//				ByteArrayOutputStream baos = new ByteArrayOutputStream();
//				ObjectOutputStream oos = new ObjectOutputStream(baos);
//				oos.write(Constant.CONN_CHECK);
//				buf = baos.toByteArray();
//				DatagramPacket packet = new DatagramPacket(buf, buf.length, address, Constant.HOST_NET_PORT);
//				socket.send(packet);
//			}catch (IOException e) {
//				ClientLogManager.logErr("call checkConnection()", e);
//				connectionStatus = -1;
//			}
//		}
//		return connectionStatus;
//	}
//	
//	public int clientConnect(){
//		return 0;
//	}
//	
//	public String[][] initMap(){		
//		return null;
//	}
//	
//	public Collection<ActiveElement> initBot(){
//		return null;
//	}
//	
//	public ActiveElement initPlayer(long playerId){
//		return null;
//	}
//	
//	public ActiveElement initPlayer(long playerId, int size, MapPoint mapPosition){
//		return null;
//	}
//	
//	public ActiveElement initBot(long botId, int size){
//		return null;
//	}
//	
//	public int sendPlayerEvent(PlayerEvent playerEvent){
//		return 0;
//	}
//	
//	public ElementState getPlayerState(long playerId){
//		return null;
//	}
//	
//	public Set<ElementState> getElementStates(long playerId){
//		return null;
//	}
//	
//	public void update(long elapsedTime){
//	}
	
}
